package cn.zifangsky.config;

import cn.zifangsky.license.LicenseCheckInterceptor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web相关配置
 * @author wb
 * @date 2023/7/9
 * @since 1.0.0
 */
@Configuration
@ConditionalOnBean(LicenseVerifyProperties.class)
public class WebMvcConfig implements WebMvcConfigurer {

    @Value("${license.verify.paths}")
    private String[] pathList;

    /**
     * 添加拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LicenseCheckInterceptor()).addPathPatterns(pathList);
    }


}
